#pragma once
#include "gtest/gtest.h"
#include "DataStructure/Input/Property/BeamSectionStandardTypes.h"
#include "../Interface/BarSectionFormulaCalculatorFactory.h"
#include "../Bar/ISectionFormulaCalculator.h"

using SG::Algebra::Point;
using namespace SG::DataStructure::FEM;
using SG::FEMSolver::Element::BarSectionFormulaCalculatorFactory;
using SG::FEMSolver::Element::ISectionFormulaCalculator;

// 将 BarSectionFormulaCalculatorFactory 生成对象测试放置在具体截面属性计算中
TEST (BarSectionFormulaCalculatorFactoryTest, ISectionCalculatorCreate)
{
    // Test data
    auto calculatorPtr = BarSectionFormulaCalculatorFactory::Create (BeamSectionStandardTypes::BEAMSECTYPE_I);
    auto ICalculatorPtr = dynamic_cast<ISectionFormulaCalculator*> (calculatorPtr.get ());

    // Check
    ASSERT_TRUE (nullptr != ICalculatorPtr);
}

// I 截面属性计算测试
TEST (BarSectionFormulaCalculatorTest, ISection)
{
    // Input data
    PBARLData section;
    section.m_id  = 2;
    section.m_mId = 3;
    section.SetGroup ("MSCBML0");
    section.SetBeamSectionStandardTypes (BeamSectionStandardTypes::BEAMSECTYPE_I);
    section.m_dimension = {6.0, 3.0, 4.5, 1.5, 1.2, 2.5};
    section.m_nsm = 10.0;

    // Test data
    ISectionFormulaCalculator calculator;
    PBARData propertyTest;
    Point centroidTest;
    calculator.Compute (section, _OUT propertyTest, _OUT centroidTest);

    // Target data
    PBARData propertyTarget;
    propertyTarget.m_id  = 2;
    propertyTarget.m_mId = 3;
    propertyTarget.m_A   = 18.3;
    // propertyTarget.m_yS = 3.6332687;
    // propertyTarget.m_zS = 0.0;
    // propertyTarget.m_yC = 2.8811478;
    // propertyTarget.m_zC = 0.0;
    propertyTarget.m_I1  = 60.2225;
    propertyTarget.m_I2  = 22.33125;
    propertyTarget.m_I12 = 0.0;
    propertyTarget.m_J   = 29.83425;
    propertyTarget.m_K1  = 0.1885246;
    propertyTarget.m_K2  = 0.6762295;
    propertyTarget.m_NSM = 10.0;
    propertyTarget.m_FE  = 0.0;
    propertyTarget.SetStressPoints ({2.5188522, 2.25, -3.4811478, 1.5, -3.4811478, -1.5, 2.5188522, -2.25});
    Point centroidTarget;

    // Check
    ASSERT_TRUE (propertyTarget == propertyTest);
    ASSERT_TRUE (centroidTarget == centroidTest);
}